//
// Created by hunan on 25-7-27.
//

#ifndef IO_REUSE_MODULE_IMPL_H
#define IO_REUSE_MODULE_IMPL_H

#include <memory>
#include <sys/epoll.h>
#include <vector>

enum EmEvent
{
    EmIoIn      = 0x01,
    EmIoOut     = 0x02,
    EmIoRdHup   = 0x04,
    EmIoErr     = 0x08,
    EmIoOneShot = 0x10,
    EmIoPost    = 0x20,
};

struct IoReuseData
{
    int              event;
    union epoll_data custom_data;
    int              description;
};

struct EventData
{
    int64_t id;
    int     events;
};

class IoReuseModuleImpl
{
public:
    IoReuseModuleImpl() = default;
    virtual ~IoReuseModuleImpl() = default;
    virtual int64_t AddEvent(int description, int event) = 0;
    virtual int64_t DelEvent(int64_t id)                 = 0;
    virtual int64_t ModEvent(int64_t id, int event)      = 0;
    virtual int     WaitEvent(std::vector<struct EventData> & trigger_event_data, int wait_time) = 0;
};

class IoReuseModuleFactory
{
public:
    IoReuseModuleFactory() = default;
    virtual ~IoReuseModuleFactory() = default;
    virtual std::shared_ptr<IoReuseModuleImpl> CreateModule() = 0;
};

#endif //IO_REUSE_MODULE_IMPL_H
